﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuimini-v2/css/public.css" media="all">
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane">
                        <div class="layui-form-item">
                            @*<div class="layui-inline">
            <label class="layui-form-label">车库编号</label>
            <div class="layui-input-inline">
                <select name="Id" lay-filter="aihao">
                    <option value="" selected="">请下拉选择</option>
                    @{ foreach (var list in ViewBag.data)
                        {
                            <option value="@list.Id">@list.parkingSpaceNumber</option>
                        }
                    }
                </select>
            </div>
        </div>*@

                            <div class="layui-inline">
                                <label class="layui-form-label">费用类型</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="expenseType" id="expenseType" class="layui-input" style="position:absolute;z-index:2;width:80%;" value="" onkeyup="search()" autocomplete="off">
                                    <select type="text" id="hc_select" lay-filter="hc_select" autocomplete="off" placeholder="移交单位全称" class="layui-select" lay-search>
                                        <option value="" selected></option>
                                        @{ foreach (var list in ViewBag.data)
                                            {
                                                <option value="@list">@list</option>
                                            }
                                        }
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">支付状态</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-filter="expenseState" lay-search id="expenseState" name="expenseState">
                                        <option value="" selected></option>
                                        <option value="待支付">待支付</option>
                                        <option value="已支付">已支付</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">支付方式</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-filter="paymentChannel" lay-search id="paymentChannel" name="paymentChannel">
                                        <option value="" selected></option>
                                        <option value="微信支付">微信支付</option>
                                        <option value="支付宝支付">支付宝支付</option>
                                        <option value="现金支付">现金支付</option>
                                        <option value="银行卡支付">银行卡支付</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>

            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                    @*<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>*@
                    @*<button class="layui-btn layui-btn-sm " lay-event="open"> 树形结构 </button>*@
                </div>
            </script>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="delete">催收</a>
                @*<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>*@
            </script>

            <script type="text/html" id="currentTableBar1">
                <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="allList">详情</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="confirm">确认</a>
            </script>

        </div>
    </div>
    <script src="/layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;

            form.on('select(hc_select)', function (data) {   //选择移交单位 赋值给input框
                $("#expenseType").val(data.value);
                $("#hc_select").next().find("dl").css({ "display": "none" });
                form.render();
            });

            window.search = function () {
                var value = $("#expenseType").val();
                $("#hc_select").val(value);
                form.render();
                $("#hc_select").next().find("dl").css({ "display": "block" });
                var dl = $("#hc_select").next().find("dl").children();
                var j = -1;
                for (var i = 0; i < dl.length; i++) {
                    if (dl[i].innerHTML.indexOf(value) <= -1) {
                        dl[i].style.display = "none";
                        j++;
                    }
                    if (j == dl.length - 1) {
                        $("#hc_select").next().find("dl").css({ "display": "none" });
                    }
                }

            }

            table.render({
                elem: '#currentTableId',
                url: '@Url.Action("GetExpenseInfoToCostDeliveryList")',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    { type: "checkbox", width: 50 },
                    @*{ field: 'Id', width: 80, title: 'Id', sort: true },*@
                    { field: 'expenseName', width: 150, title: '费用名称', sort: true },
                    { field: 'expenseType', width: 150, title: '费用类型' },
                    { field: 'expenseNumber', width: 150, title: '费用金额' },
                    { field: 'expenseState', width: 120, title: '费用状态', sort: true },
                    { field: 'expenseBelong', width: 120, title: '费用所属', sort: true },
                    { field: 'paidInAmount', width: 120, title: '实缴金额', sort: true },
                    { field: 'paymentChannel', width: 120, title: '缴费途径', sort: true },
                    { field: 'payment', width: 120, title: '缴费人', sort: true },
                    { field: 'createTime', width: 120, title: '创建时间', sort: true },
                    { field: 'remark', width: 200, title: '备注', sort: true },
                    @*{ title: '检修', minWidth: 150, toolbar: '#currentTableBar1', align: "center" },*@
                    { title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center" }
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 5,
                page: true,
                skin: 'line'
            });

            // 监听搜索操作
            form.on('submit(data-search-btn)', function (data) {
                //data.title
                var result = JSON.stringify(data.field);
                @*layer.alert(result, {
                    title: '最终的搜索信息'
                });*@

                //执行搜索重载
                table.reload('currentTableId', {
                    page: {
                        curr: 1
                    }
                    , where: {
                        expenseType: data.field.expenseType,
                        expenseState: data.field.expenseState,
                        paymentChannel: data.field.paymentChannel
                    }
                }, 'data');

                return false;
            });

            /**
             * toolbar监听事件
             */
            table.on('toolbar(currentTableFilter)', function (obj) {
                if (obj.event === 'add') {  // 监听添加操作
                    var index = layer.open({
                        title: '添加费用信息',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '80%'],
                        content: '@Url.Action("AddExpenseInfo")',
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                } else if (obj.event === 'delete') {  // 监听删除操作
                    var checkStatus = table.checkStatus('currentTableId')
                        , data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                } else if (obj.event === 'open') {
                    var listIndex = layer.open({
                        title: 'Excel表导入',
                        type: 2,
                        shade: 0.2,
                        maxmin: false,
                        shadeClose: false,
                        area: ['100%', '100%'],
                        content: '@Url.Action("TreeMenusList")'
                    })
                    $(window).on("resize", function () {
                        layer.full(listIndex);
                    });
                }
            });

            //监听表格复选框选择
            table.on('checkbox(currentTableFilter)', function (obj) {
                console.log(obj)
            });

            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') {
                    var index = layer.open({
                        title: '编辑车位销售信息',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '80%'],
                        content: '@Url.Action("EditRentInfo")/' + data.Id,
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                } else if (obj.event === 'delete') {
                    layer.confirm('真的右键催收吗？', function (index) {
                        $.ajax({
                            url: "@Url.Action("SetEmailToDebtor")",
                            type: "post",
                            data: { id: data.Id },
                            success: function (da) {
                                console.log(da)
                                layer.msg(da.msg)
                            },
                        })
                        obj.del();
                        layer.close(index);
                    });
                } else if (obj.event === 'allList') {
                    var index = layer.open({
                        title: '检修详情',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '80%'],
                        content: '@Url.Action("AllMaterialMaintenance")/' + data.Id,
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                } else if (obj.event === 'confirm') {
                    var index = layer.open({
                        title: '确认检修',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '80%'],
                        content: '@Url.Action("ConfirmMaterial")/' + data.Id,
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                }
            });

        });
    </script>

</body>
</html>